﻿using System;
using System.Xml;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace NHTLibrary
{
    public class ServerCore
    {
        #region FIELDS
        private Dictionary<Int16, Int16> _serverCodeData;
        private Dictionary<String, String> _serverNameData;
        #endregion

        public ServerCore()
        {
            // --- INITIALIZATION
            _serverCodeData = new Dictionary<Int16, Int16>();
            _serverNameData = new Dictionary<String, String>();

            // --- SERVER-DATA
            var xmlDoc = new XmlDocument();
            xmlDoc.Load("UserData/Config/ServerList.xml");

            var nodes = xmlDoc.SelectNodes("//Server");
            short _currentServer = 0;

            foreach (XmlNode node in nodes)
            {
                _currentServer += 1;
                _serverCodeData.Add(_currentServer, Convert.ToInt16(node["Id"].InnerText));
                _serverNameData.Add(node["Name"].Attributes["Key"].InnerText, node["Name"].InnerText);
            }
        }

        public Int16 this[Int16 index]
        {
            get { return _serverCodeData[index]; }
        }

        public String this[String index]
        {
            get { return _serverNameData[index]; }
        }
    }
}
